﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.IO;
using System.Text;
using System.Collections;
using System.Data;
using BSCMFF.Core.BusinessLayer;
using System.Data.SqlClient;
using Telerik.Web.UI;
using BSCMFF.Core;
//using BSCMFF.Core.MembershipDataProvider;

namespace BSCMFF.Web
{
    public partial class Default2 : MultiLanguagePage // System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //v.FindControl("labadmin"
            //BSCMFF.Core.MembershipDataProvider.EntityMembershipDataProvider ep = new Core.MembershipDataProvider.EntityMembershipDataProvider();
            //User u = ep.GetUser();
            //string login = User.Identity.Name;
            //BSCMFF.Core.RoleDataProvider.EntityRoleDataProvider er = new Core.RoleDataProvider.EntityRoleDataProvider();

            //lRole.Text = login + " a mas rolu: " + er.GetRolesForUser(login)[0];

            //MultiLanguagePage mlp = new MultiLanguagePage();

            //BSCMFF.Core.MultiLanguagePage
            //Class1
        }

        protected void RadTreeView1_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
        {
            // l.Text = RadTreeView1.SelectedNode.Text;
        }

        public void log_click(object sender, EventArgs e)
        {
            //BSCMFF.Core.BusinessLayer.UserManager bu = new Core.BusinessLayer.UserManager();
            //bu.Validate();
        }

        protected void BUttonImportUsers_Click(object sender, EventArgs e)
        {

            List<string[]> parsedData = new List<string[]>();

            CSVReader reader = new CSVReader(RadUploadCSV.UploadedFiles[0].InputStream);

            //get the header

            string[] headers = reader.GetCSVLine();

            DataTable dtOk = new DataTable();
            DataTable dtError = new DataTable();
            DataTable dtPreview = new DataTable();


            //add headers

            foreach (string strHeader in headers)
            {
                dtOk.Columns.Add(strHeader);
                dtError.Columns.Add(strHeader);
                dtPreview.Columns.Add(strHeader);
            }


            string[] data;
            int previewCount = 0;

            while ((data = reader.GetCSVLine()) != null)
            {
                if (CheckBox(data))
                {
                    dtOk.Rows.Add(data);
                    if(previewCount++ < 10)
                    {
                        dtPreview.Rows.Add(data);
                    }

                }
                else
                {
                    dtError.Rows.Add(data);
                }
            }

            //RadGrid g = new RadGrid();
            g.DataSource = dtPreview;
            g.DataBind();


            
           // Page.Controls.Add(g);

        }

        private bool CheckBox(string[] data)
        {
            return true; // throw new NotImplementedException();
        }

    }



     

  
}